package com.lmb.controller;

import com.lmb.bean.Families;
import com.lmb.mapper.FamiliesDao;
import com.lmb.service.FamiliesService;
import com.lmb.util.Page;
import com.lmb.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/families")
public class FamiliesController {
    @Autowired
    FamiliesDao familiesDao;
    @Autowired
    FamiliesService familiesService;
    @PostMapping
    public Result add(@RequestBody Families families)
    {
        Object obj=familiesService.add(families);
        return Result.success(obj);
    }
    @DeleteMapping("{id}")
    public Result del(@PathVariable("id") Integer id){
        Object obj=familiesService.del(id);
        return Result.success(obj);
    }
    @PutMapping
    public Result edit(@RequestBody Families families){
        Object obj=familiesService.edit(families);
        return Result.success(obj);
    }
    @GetMapping("all")
    public Result all( Families families){
        Object obj=familiesService.all(families);
        return Result.success(obj);
    }
    @GetMapping("{id}")
    public Result one(@PathVariable("id") Integer id){
        Object obj=familiesService.one(id);
        return Result.success(obj);
    }
    @GetMapping("page")
    public Result page(Page page, Families families){
        familiesService.page(page,families);
        return Result.success(page);
    }
}
